
# add the binary tree to the search path for include files
include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/src/contrib" "${PROJECT_BINARY_DIR}")

set (HEADERS "${PROJECT_BINARY_DIR}/config.h"
             "${PROJECT_SOURCE_DIR}/src/contrib/cJSON.h"
             "${PROJECT_SOURCE_DIR}/src/contrib/CJsonObject.hpp"
             "${PROJECT_SOURCE_DIR}/src/contrib/tinyxml2.h"
             "${CMAKE_CURRENT_SOURCE_DIR}/JsonObjectBase.hxx"
             "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")

set (SOURCES "${PROJECT_SOURCE_DIR}/src/contrib/cJSON.c"
             "${PROJECT_SOURCE_DIR}/src/contrib/CJsonObject.cpp"
             "${PROJECT_SOURCE_DIR}/src/contrib/tinyxml2.cpp"
             "${CMAKE_CURRENT_SOURCE_DIR}/JsonObjectBase.cxx"
             "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")

# add the executable
add_executable(test-result ${HEADERS} ${SOURCES})
link_directories("${PROJECT_SOURCE_DIR}/rutil")
target_link_libraries(test-result rutil)

if(MSVC)
    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
    # ws2_32.lib @ windows socket library
    # winmm.lib @ import timeGetTime
    target_link_libraries(test-result ws2_32 winmm)
else()
    # pthread @ windows socket library
    target_link_libraries(test-result pthread)
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -Wall -g -ggdb")
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -Wall")
endif()

# add the install targets
install (TARGETS test-result DESTINATION bin)